#include <regx52.h>
unsigned int note[] = {190, 170, 150, 140, 127, 113, 100};
idata char LiangZhiLaoHu[] = {
0,1,2,0,      
2,3,4,4,'.',
4,5,4,3,2,0,
1,-4,0,0,
	'S'
};

idata char XiaoXiaoXingXing[] = {
0,0,4,4,5,5,4,4,
3,3,2,2,1,1,0,0,
4,4,3,3,2,2,1,1,	
4,4,3,3,2,2,1,1,
	'S'
};

char* music[] = {LiangZhiLaoHu, XiaoXiaoXingXing};

unsigned char n = 0;
unsigned int count = 0;
unsigned char pause = 0;

void delay(unsigned int i);

void play(const char* ptr_music) 
{
	char curr = ptr_music[n];
	unsigned int  T;
	
	if(pause) 
	{
		return;
	}
	if(curr == '.') 
	{
		T = 150;
	} else {
		if(curr < 0) 
		{
			T = note[4] + 70;
		} else {
			T = note[curr];
		}
		P1_5 = !P1_5;
	}
	delay(T);
	
	if(count++ * T > 15000) 
	{	
		count = 0;
		n++;
		if(ptr_music[n] == 'S') 
		{
			n=0;
		}
	}
}